<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="uiTags" prefix="ui"%>

<ui:body>
	<div class="easyui-layout" style="width: 100%;height: 100%;" fit="true">
		<div data-options="region:'north',border:false" style="height: 110px">
			<ui:formtable id="usermanageForm" formlabel="用户查询">
				<ui:textinput id="login_id" label="登录名"  />
				<ui:textinput id="name" label="姓名"  />
				<ui:buttons>
					<ui:button onclick="userManage.queryuser()" value="查询" id="query" />
				</ui:buttons>
			</ui:formtable>
		</div>
		<div data-options="region:'center',border:false" style="overflow: hidden;" >
			<ui:datagrid id="usermanageGrid" title="用户信息" dbclick="userManage.userview()">
				<ui:dgtoolbar exportflag="true">
					<ui:button onclick="userManage.userAdd()" value="新增" icon="icon-add" />
					<ui:button onclick="userManage.useredit()" value="编辑"  icon="icon-mini-edit" />
					<ui:button onclick="userManage.userdelete()" value="删除"  icon="icon-remove" />
					<ui:button onclick="userManage.userview()" value="查看"  icon="icon-search" />
				</ui:dgtoolbar>
				<ui:columntext  filed="userid" text="" hidden="true"/>
				<ui:columntext text="登录名" filed="login_id"/>
				<ui:columntext text="姓名" filed="name" />
				<ui:columntext text="角色id" filed="roleid" hidden="true"/>
				<ui:columntext text="角色名称" filed="rolename"/>
			</ui:datagrid>
		</div>
	</div>
</ui:body>
<script type="text/javascript">
var userManage={
	queryuser:function(){
		var params = new Object();
		params.login_id = getObject("login_id").val();
		params.name = getObject("name").val();
		asyRefreshDatagrid("usermanageGrid","user/queryUsers",params);
	},
	userAdd:function(){
		createResponse("新增用户", 800, 500, "user/enterUseradd", "userManage.queryuser()")
	},
	useredit:function(){
		var row = getSelectedRow("usermanageGrid");
		var userid;
		if(row){
			userid = row.userid;
			createResponse("修改",800,500,"user/enterUserEdit?userid=" + userid,"userManage.queryuser()");
		}else{
			showWarnAlert("请先选中后再操作！");
			return;
		}	
	},
	
	userview:function(){
		var row = getSelectedRow("usermanageGrid");
		var userid;
		if(row){
			userid = row.userid;
			createResponse("查看",800,500,"user/enterUserView?userid=" + userid,"userManage.queryuser()");
		}else{
			showWarnAlert("请先选中后再操作！");
			return;
		}	
	},
	userdelete:function(){
		var row = getSelectedRow("usermanageGrid");
		var userid;
		if(row){
			userid = row.userid;
			var params = new Object();
			params.userid = userid;
			ajaxRequest("user/delete",params);
			queryuser();
			showWarnAlert("删除成功！");
		}else{
			showWarnAlert("请先选中后再操作！");
			return;
		}	
	}
}
userManage.queryuser();
</script>